package com.hyt.it.ogt.kq.service.gov.photo;

import com.hyt.it.ogt.kq.common.exception.GovInvalidRequestException;
import com.hyt.it.ogt.kq.common.gov.constant.ResponseCode;

import lombok.Getter;

/**
 * <p>
 * 考生照片类型枚举
 * </p>
 *
 * @author huangyh
 * @since 2021-08-10
 */
@Getter
public enum PhotoTypeEnum {

    /**
     * 考生个人照
     */
    PERSONAL(1, "考生个人照"),
    ID_CARD_FRONT(2, "考生证件照正面"),
    ID_CARD_BACK(3, "考生证件照反面"),

    ;

    /**
     *  编码
     */
    private final Integer code;
    /**
     * 备注
     */
    private final String remark;

    PhotoTypeEnum(int code, String remark) {
        this.code = code;
        this.remark = remark;
    }

    /**
     * 获取照片类型
     * @param code 照片类型编号
     * @return 照片类型枚举
     * @throws GovInvalidRequestException 请求不合法
     */
    public static PhotoTypeEnum getByCode(Integer code) throws GovInvalidRequestException {
        for (PhotoTypeEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        //照片类型不存在
        throw new GovInvalidRequestException(ResponseCode.ERROR_BATCH_IMPORT_CANDIDATE_PHOTO_TYPE_NON_EXISTENT.getCode(),ResponseCode.ERROR_BATCH_IMPORT_CANDIDATE_PHOTO_TYPE_NON_EXISTENT.getMsg());
    }

}
